package com.time.on.device.helper;

import java.text.ParseException;
import java.util.concurrent.TimeUnit;

import android.annotation.SuppressLint;

public class TimeHelper {

	@SuppressLint("DefaultLocale")
	public static String timeToString(long millis) throws ParseException {
		String hms = String.format(
				"%02d:%02d:%02d",
				TimeUnit.MILLISECONDS.toHours(millis),
				TimeUnit.MILLISECONDS.toMinutes(millis)
						- TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
								.toHours(millis)),
				TimeUnit.MILLISECONDS.toSeconds(millis)
						- TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
								.toMinutes(millis)));
		return hms;
	}

	public static long timeToMilis(Integer hours, Integer minutes) {

		long milis = ((hours * 60) + minutes) * 60 * 1000;

		return milis;

	}
}
